﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace cn.Util
{
    /// <summary>
    /// 消息传递封装
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class ReturnValue<T>
    {

        string _ErrorDetailed;
        /// <summary>
        /// 错误详细消息
        /// </summary>
        public string ErrorDetailed
        {
            get { return _ErrorDetailed; }
            set { _ErrorDetailed = value; }
        }

        string _ErrorSimple;
        /// <summary>
        /// 错误消息
        /// </summary>
        public string ErrorSimple
        {
            get { return _ErrorSimple; }
            set { _ErrorSimple = value; }
        }

        T _Value;
        /// <summary>
        /// 返回数据
        /// </summary>
        public T Value
        {
            get { return _Value; }
            set { _Value = value; }
        }

        ReturnEnum _Status= ReturnEnum.UnKnow;
        /// <summary>
        /// 返回值状态
        /// </summary>
        public ReturnEnum Status
        {
            get { return _Status; }
            set { _Status = value; }
        }

        /// <summary>
        /// 正确
        /// </summary>
        /// <param name="_Value"></param>
        public void True(T _Value)
        {
            Status = ReturnEnum.Yes;
            Value = _Value;
        }

        /// <summary>
        /// 错误
        /// </summary>
        /// <param name="_ErrorSimple">简单说明</param>
        /// <param name="_ErrorDetailed">详细说明（一般异常用）</param>
        public void False(string _ErrorSimple = "", string _ErrorDetailed = "")
        {
            Status = ReturnEnum.No;
            ErrorSimple = _ErrorSimple;
            ErrorDetailed = _ErrorDetailed;
            if (ErrorDetailed.Length == 0)
            {
                ErrorDetailed = ErrorSimple;
            }
        }

    }
}
